//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <fstream>

#include "ListAmylogenic.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main(int argc, char** argv) {

  String* filenameFASTASeq;
  String* filenameAmylogenicSeq;
  String* filenameFASTASeqShuffle;
  String* filenameAmylogenicSeqShuffle;
  String* filenameOut;

  if (argc < 6) {
    cout << "Error in the input arguments. The execution must be: " << endl;
    cout << "./AmylogenicAnalysis <FASTA Seq Input File> <Amylogenic Seq Result> <FASTA Seq Shuffle Input File> <Amylogenic Seq Shuffle Result> <Output Name>" << endl;
    return 0;
  }
  else {
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "          FASTA Seq Input File : " << argv[1] << endl;
    cout << "         Amylogenic Seq Result : " << argv[2] << endl;
    cout << "  FASTA Seq Shuffle Input File : " << argv[3] << endl;
    cout << " Amylogenic Seq Shuffle Result : " << argv[4] << endl;
    cout << "                   Output Name : " << argv[5] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    filenameFASTASeq              = new String(argv[1]);
    filenameAmylogenicSeq         = new String(argv[2]);
    filenameFASTASeqShuffle       = new String(argv[3]);
    filenameAmylogenicSeqShuffle  = new String(argv[4]);
    filenameOut                   = new String(argv[5]);
  }

  ListAmylogenic* listAmylogenic = new ListAmylogenic();

  listAmylogenic->FilenameFASTASeq(filenameFASTASeq);
  listAmylogenic->FilenameAmylogenicSeq(filenameAmylogenicSeq);
  listAmylogenic->FilenameFASTASeqShuffle(filenameFASTASeqShuffle);
  listAmylogenic->FilenameAmylogenicSeqShuffle(filenameAmylogenicSeqShuffle);
  listAmylogenic->FilenameOut(filenameOut);
  
  listAmylogenic->LoadData();
  listAmylogenic->DeleteIncompleteData();
  
  String* temporalName = new String ();
  
  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequences.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqAmylogenicRegions(temporalName);
  
  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequences.No.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Shuffle.Sequences.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Shuffle.Sequences.No.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqShuffleNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.Amyloid.Regions.With.Shuffle.Sequences.No.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqAmylogenicShuffleNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.No.Amyloid.Regions.With.Shuffle.Sequences.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqNoAmylogenicShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.Amyloid.Regions.With.Shuffle.Sequences.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqAmylogenicShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.No.Amyloid.Regions.With.Shuffle.Sequences.No.Amyloid.Regions.fasta");
  listAmylogenic->GetListSeqNoAmylogenicShuffleNoAmylogenicRegions(temporalName);

  cout << "Frequencies" << endl;
  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequences.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqAmylogenicRegions(temporalName);
  
  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequences.No.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Shuffle.Sequences.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Shuffle.Sequences.No.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqShuffleNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.Amyloid.Regions.With.Shuffle.Sequences.No.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqAmylogenicShuffleNoAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.No.Amyloid.Regions.With.Shuffle.Sequences.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqNoAmylogenicShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.Amyloid.Regions.With.Shuffle.Sequences.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqAmylogenicShuffleAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Original.Sequence.No.Amyloid.Regions.With.Shuffle.Sequences.No.Amyloid.Regions.AminoAcid.Frequency.dat");
  listAmylogenic->GetFreqAAListSeqNoAmylogenicShuffleNoAmylogenicRegions(temporalName);

  
  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Percent.Amyloid.Regions.dat");
  listAmylogenic->GetFreqPercentAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Amyloid.Regions.stat");
  listAmylogenic->StatisticalOutComplete(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Percent.Seq.Amyloid.Regions.dat");
  listAmylogenic->GetPercentOfSeqAmylogenicRegions(temporalName);

  cout << "---------------------------------------------------------------------------------" << endl;
  temporalName->In(filenameOut); temporalName->Add(".Percent.Seq.Shuffle.Amyloid.Regions.dat");
  listAmylogenic->GetPercentOfSeqShuffleAmylogenicRegions(temporalName);

  if (temporalName) delete temporalName;

  cout << "---------------------------------------------------------------------------------" << endl;

  if (filenameFASTASeq)             delete filenameFASTASeq;
  if (filenameAmylogenicSeq)        delete filenameAmylogenicSeq;
  if (filenameFASTASeqShuffle)      delete filenameFASTASeqShuffle;
  if (filenameAmylogenicSeqShuffle) delete filenameAmylogenicSeqShuffle;
  if (filenameOut)                  delete filenameOut;

  if (listAmylogenic)               delete listAmylogenic;

  return 1;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//


